package com.chance.cc.crawler.development.command.meta.keyword.ifeng;

import com.chance.cc.crawler.development.command.meta.keyword.CrawlerDomainKeywordCommand;
import com.chance.cc.crawler.meta.core.bean.crawler.CrawlerDomainKeys;
import org.apache.commons.lang.StringUtils;

import java.io.*;

/**
 * @ClassName song
 * @Description TODO
 * @Author ding
 * @Date 2021/9/3 11:27
 * @Version 1.0
 * 凤凰网 车系文章采集
 * 关键词  http://192.168.1.215:9599/v1/meta/ifeng/keys?site=SeriesArticle
 *
 **/
public class IFengKeyword {
    private static final String domain = "ifeng";
    private static final String site = "SeriesArticle";
    private static final String path = "E:\\chance-crawler-development\\crawler-scripts-command\\src\\main\\java\\com\\chance\\cc\\crawler\\development\\command\\meta\\keyword\\ifeng\\ifeng_series.txt";

    private static final String host = "192.168.1.215";
    private static final Integer port = 9599;

    public static void main(String[] args) throws IOException {
        BufferedReader bufferedReader = new BufferedReader(new InputStreamReader(new FileInputStream(new File(path)),"UTF-8"));
        String lineData = null;
        while((lineData = bufferedReader.readLine()) !=null){
            if (StringUtils.isBlank(lineData)){
                continue;
            }
            CrawlerDomainKeywordCommand crawlerDomainKeywordCommand = new CrawlerDomainKeywordCommand(host,port);
            CrawlerDomainKeys crawlerDomainKeys = new CrawlerDomainKeys();
            crawlerDomainKeys.setDomain(domain);
            crawlerDomainKeys.setSite(site);
            crawlerDomainKeys.setKeyword(lineData);
            crawlerDomainKeys.setStatus(0);
            crawlerDomainKeywordCommand.addOrUpdateKeys(crawlerDomainKeys);
            System.out.println(lineData);
        }
    }

}
